package com.banyuan.controller;

import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

@Controller
public class UploadController {
    @RequestMapping("/upload")
    public String upload(@RequestParam("imageHeader") MultipartFile multipartFile) throws IOException {
        String originalFilename = multipartFile.getOriginalFilename();
        InputStream is = multipartFile.getInputStream();
        FileOutputStream fileOutputStream = new FileOutputStream("/Users/edy/Desktop/" + originalFilename);
        IOUtils.copy(is,fileOutputStream);
        return "success";
    }
}
